<%-- 
    Document   : menu2
    Created on : 14-jul-2014, 11:29:16
    Author     : romulogalindo
--%>

<%@page import="java.util.List"%>
<%@page import="acceso.login.Item"%>
<%@page import="acceso.login.Menu"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    Object core = request.getAttribute("menu");
    if (core != null) {
        out.println("<ul class=\"megamenu level0\">");
        List menu = (List) request.getAttribute("menu");
        for (Object menu0 : menu) {
            if (menu0 instanceof Item) {
                out.println(crearItem((Item) menu0, 0));

            } else if (menu0 instanceof Menu) {
                out.println(crearMenu((Menu) menu0, 0));

            }
        }
        out.println("</ul>");

    }

    String menu = request.getAttribute("menu").toString();
    System.out.println("menu:\n" + menu);
%>

<%!
    public String crearItem(Item item, int nivel) {
        String itemString = "<li class=\"mega\">";
        itemString = itemString + "<a href=\"" + item.getUrl() + "\" id=\"menu0\" onclick=\"item_activo('menu0')\" title=\"" + item.getDescripcion() + "\" class=\"mega ${active?'active':''}\" target=\"" + item.getTarget() + "\" >"
                + "<span class=\"menu-title\">" + item.getDescripcion() + "</span>"
                + "</a>";

        itemString = itemString + "</li>";
        return itemString;
    }

    public String crearMenu(Menu menu, int nivel) {
        String menuString = "<li class=\"mega haschild\">";
        menuString = menuString + "<a href=\"#\" id=\"menu0\" onclick=\"item_activo('menu0')\" title=\"" + menu.getDescripcion() + "\" class=\"mega ${active?'active':''}\" >"
                + menu.getDescripcion()
                + "</a>";

        menuString = menuString + "</li>";

        return menuString;
    }
%>